<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class CreateStepUpstreamOutsideTable extends AbstractMigration
{
    public function up()
    {
        $table = $this->table('step_upstream_outside', ['id' => false, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci']);

        //添加数据字段
        $table->addColumn('id', 'integer', ['identity' => true, 'signed' => false, 'limit' => 11, 'comment' => '工序上游ID'])
            ->addColumn('step_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '所属工序ID'])
            ->addColumn('type', 'char', ['default' => 'step', 'limit' => 12, 'comment' => '上游类型（当前默认是工序 step）'])
            ->addColumn('config', 'json', ['null' => true, 'comment' => '外包工序上游配置'])
            ->addColumn('created', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '创建时间']);

        //执行创建
        $table->create();
    }

    public function down()
    {
        $this->table('step_upstream_outside')->drop()->save();
    }
}
